package algo.math.evaluator.context.functions;

import algo.math.evaluator.value.IValue;
import algo.math.evaluator.value.IValue.Compare;

/**
 * Maximum value between two values
 */
public class Max extends Function {


	public Max()
	{
		super._name = "max";
		super._argsNb = 2;
	}

	/* (non-Javadoc)
	 * @see algo.math.evaluator.context.functions.Function#resolve(algo.math.evaluator.value.IValue[])
	 */
	@Override
	public IValue resolve(IValue[] args) {
		
		if (args.length == super._argsNb)
		{
		if (args.length >0)
		{
			IValue max = args[0];
		
		for (IValue i : args)
		{
			if (i.compareTo(max)==Compare.SUPERIOR)
			{
				max = i;
			}
		}
		return max;
		}
		return null;
		
		}
		return null;
	}
	
	
}
